package com.File;

public class DiedLock {
    public static void main(String[] args) {
        DiedLockDemo demo = new DiedLockDemo(true);
        DiedLockDemo demo1 = new DiedLockDemo(false);
        demo.start();
        demo1.start();

    }
}

class DiedLockDemo extends Thread {
    static Object o1 = new Object();
    static Object o2 = new Object();
    boolean doop;

    public DiedLockDemo(boolean doop) {
        this.doop = doop;
    }

    @Override
    public void run() {
        if (doop) {
            synchronized (o1) {
                System.out.println(Thread.currentThread().getName() + "inter o1");
                synchronized (o2) {
                    System.out.println(Thread.currentThread().getName() + "inter o2");
                }
            }
        } else {
            synchronized (o2) {
                System.out.println(Thread.currentThread().getName() + "inter o2");
                synchronized (o1) {
                    System.out.println(Thread.currentThread().getName() + "inter o1");
                }
            }
        }
    }
}